/*
 * @Author: huangwei
 * @Date: 2021-04-19 10:31:45
 * @LastEditors: 黄威
 * @LastEditTime: 2021-12-27 14:28:47
 * @Description: 打包为Api的入口文件
 */

import MgsLMap from './components/MgsLMap'
import MgsCView from './components/MgsCView'
import MgsViewCompare from './components/MgsViewCompare'

// utils
import * as service from './utils/service-creator'
import * as coord from './utils/coordinate' //坐标转换
import * as projection from './utils/projection' //坐标转换

// services
import analysis from './services/analysis'

// directives
import clickoutside from './directives/clickoutside'
import drag from './directives/drag'

// 需要设置外部配置项的工具项
import { setSettings } from './settings'

// 组件集合
const components = {
    MgsLMap,
    MgsCView,
    MgsViewCompare,
}

const install = function (Vue, settings = {}) {
    // 初始化配置项
    setSettings(settings)

    // 组件注册
    for (const key in components) {
        const component = components[key]
        Vue.component(key, component)
    }
}

// auto install
if (typeof window !== 'undefined' && window.Vue && window.Vue.autoInstall) {
    install(window.Vue)
}

const API = {
    version: require('../package.json').version,
    install,
    ...components,
    utils: { service, coord, projection },
    services: { analysis },
    directives: { clickoutside, drag },
}

export default API
